//
//  SecureTextEntryView.h
//  SecureTextEntryView
//
//  Created by 杨林杰 on 2019/5/18.
//  Copyright © 2019 YLJ. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class SecureTextEntryView;
@class SecureTextEntryViewConfig;

@protocol SecureTextEntryDelegate <NSObject>
/**
 开始输入
 */
- (void)secureTextEntryBegin:(SecureTextEntryView *)secureTextEntryView;
/**
 结束输入
 */
- (void)secureTextEntryEnd:(SecureTextEntryView *)secureTextEntryView;
/**
 输入改变
 */
- (void)secureTextEntryDidChange:(SecureTextEntryView *)secureTextEntryView;
/**
 输入完成
 */
- (void)secureTextEntryComplete:(SecureTextEntryView *)secureTextEntryView;
/**
 点击删除
 */
- (void)secureTextEntryDidDelete:(SecureTextEntryView *)secureTextEntryView;

@end

@interface SecureTextEntryView : UIView<UIKeyInput>

/**
 协议
 */
@property (nonatomic, weak) id<SecureTextEntryDelegate> delegate;

/**
 输入文本
 */
@property (nonatomic, strong, readonly) NSMutableString *text;

/**
 更新输入框配置
 */
- (void)updateConfig:(void(^)(SecureTextEntryViewConfig *config))configBlock;
/**
 重置安全码
 */
- (void)reset;

@end

@interface SecureTextEntryViewConfig : NSObject

/**
 密码长度
 */
@property (nonatomic, assign) NSUInteger count;

/**
 输入框大小
 */
@property (nonatomic, assign) CGFloat inputWidth;
/**
 输入框背景色
 */
@property (nonatomic, strong) UIColor *inputBackgroundColor;
/**
 安全码半径
 */
@property (nonatomic, assign) CGFloat radius;
/**
 边距相对中间间隙倍数
 */
@property (nonatomic, assign) CGFloat multiple;
/**
 安全码颜色
 */
@property (nonatomic, strong) UIColor *pointColor;
/**
 边框颜色
 */
@property (nonatomic, strong) UIColor *borderColor;

/**
 控件背景色
 */
@property (nonatomic, strong) UIColor *backgroundColor;
/**
 是否允许三方键盘，默认NO
 */
@property (nonatomic, getter=isThreePartyKeyboard) BOOL threePartyKeyboard;

+ (instancetype)defaultConfig;

@end

NS_ASSUME_NONNULL_END
